﻿using System.Collections.Generic;

namespace KeyWordSearch.ProcessTree
{
	public class ExecuteResult
	{
		internal ExecuteResult(bool answer)
		{
			ResultElements = new List<ExecuteResultElement>();
			Answer = answer;
		}

		public bool Answer
		{
			get;
			internal set;
		}

		public List<ExecuteResultElement> ResultElements
		{
			get;
			private set;
		}

		internal void Merge(ExecuteResult mergeTo,bool IsOR)
		{
			for (int i = 0; i < mergeTo.ResultElements.Count; i++)
			{
				ResultElements.Add(mergeTo.ResultElements[i]);
			}

			if (IsOR)
			{
				Answer |= mergeTo.Answer;
			}
			else
			{
				Answer &= mergeTo.Answer;
			}
		}
	}
}
